﻿#define _CRT_SECURE_NO_WARNINGS 1

// 1.经此一役小红所向无敌
#include <iostream>
using namespace std;
#define int long long
int a, h, b, k;
signed main() {
	cin >> a >> h >> b >> k;
	int sum = 0;
	int cnt1 = h / b;
	int cnt2 = k / a;
	if (h % b != 0)
		cnt1++;
	if (k % a != 0)
		cnt2++;
	int cnt = min(cnt1, cnt2);
	sum += (cnt + 1) * (a + b);
	if (cnt1 == cnt2)
		cout << sum << endl;
	else if (cnt1 > cnt2)
	{
		sum += a * 10;
		cout << sum << endl;
	}
	else if (cnt1 < cnt2)
	{
		sum += b * 10;
		cout << sum << endl;
	}
	return 0;
}

// 2.连续子数组最大和
#include <iostream>
using namespace std;

const int N = 2e5 + 10;
int dp[N];
int v[N];
int main() {
	int n;
	cin >> n;

	for (int i = 1; i <= n; ++i)
		cin >> v[i];

	for (int i = 1; i <= n; ++i)
		dp[i] = max(dp[i - 1] + v[i], v[i]);

	int ret = -101;
	for (int i = 1; i <= n; ++i)
		ret = max(dp[i], ret);

	cout << ret << endl;
	return 0;
}

// 3.非对称之美
#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int fun()
{
	// 1. 判断是否全都是相同字符
	bool flag = false;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[0])
		{
			flag = true;
			break;
		}
	}
	if (flag == false) return 0;
	// 2. 判断本⾝是否是回⽂
	flag = true;
	int left = 0, right = n - 1;
	while (left < right)
	{
		if (s[left] == s[right])
		{
			left++;
			right--;
		}
		else
		{
			flag = false;
			break;
		}
	}

	if (flag) return n - 1;
	else return n;
}
int main()
{
	cin >> s;
	n = s.size();

	cout << fun() << endl;

	return 0;
}